#include "terminal.h"
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

static struct termios terminal_config;

int load_terminal_config(void) {
    return tcgetattr(STDIN_FILENO, &terminal_config);
}

int reset_terminal_config(void) {
    return tcsetattr(STDIN_FILENO, TCSANOW, &terminal_config);
}

int set_terminal_raw_mode(void) {
    struct termios temp_terminal_config = terminal_config;
    temp_terminal_config.c_lflag &= ~(ICANON | ECHO);
    return tcsetattr(STDIN_FILENO, TCSANOW, &temp_terminal_config);
}